package com.hisan.freeride.home.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hisan.freeride.R;
import com.hisan.freeride.home.model.WoMessage;


import java.util.List;

/**
 * 创建时间 : 2017/6/8
 * 创建人：yangyingqi
 * 公司：嘉善和盛网络有限公司
 * 备注：我的消息适配器
 */
public class MessageAdapter extends RecyclerView.Adapter {
    private LayoutInflater mInflater;
    private List<WoMessage> mList;

    public MessageAdapter(Context context, List<WoMessage> list) {
        mInflater = LayoutInflater.from(context);
        mList = list;
    }

    public void setData( List<WoMessage> list){
        mList = list;
        notifyDataSetChanged();
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MessageViewHolder(mInflater.inflate(R.layout.recyclerview_item_layout, parent, false));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
        final MessageViewHolder viewHolder = (MessageViewHolder) holder;
        viewHolder.message_id.setText(mList.get(position).getId()+"");
        viewHolder.message_name.setText(mList.get(position).getTitle());
        viewHolder.message_data.setText(mList.get(position).getCreate_time());
        viewHolder.message_news.setText(mList.get(position).getDescription());
        if (mList.get(position).getMark()==0) {
            viewHolder.stauts.setVisibility(View.VISIBLE);
        }else{
            viewHolder.stauts.setVisibility(View.INVISIBLE);
        }
    }

    @Override
    public int getItemCount() {
        return mList != null ? mList.size() : 0;
    }


}
